<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:fn="http://java.sun.com/jsp/jstl/functions"
                template="/templates/ui.xhtml">

    <ui:define name="head">
        <style type="text/css">
            .col-95 {
                width: 95%;
            }

            .col-5 {
                width: 5%;
            }
        </style>

    </ui:define>

    <ui:define name="content">
        <div style="margin:5px;">
            <h:form id="form">
                <p:growl id="msgs" showDetail="false" life="5000"/>

                <div id="header">
                    <p:panel header="客户信息管理">
                        <h:panelGrid columns="2" cellspacing="5" columnClasses="col-95,col-5">
                            <h:panelGrid columns="4" cellspacing="5">
                                <h:outputLabel value="分支机构:"/>
                                <h:selectOneMenu id="branchname"
                                                 value="#{custMngAction.paramBean.branchId}">
                                    <f:selectItems value="#{custMngAction.branchList}"/>
                                </h:selectOneMenu>
                                <h:outputLabel value="客户经理:"/>
                                <h:selectOneMenu id="custmgr0" value="#{custMngAction.paramBean.custmgrId}">
                                    <f:selectItems value="#{custMngAction.custmgrList}"/>
                                </h:selectOneMenu>
                                <h:outputLabel value="报表类别:"/>
                                <p:inputText  value="#{custMngAction.paramBean.rptType}"/>

                                <h:outputLabel value="报表日期:"/>
                                <p:inputText id="startDate" value="#{custMngAction.paramBean.rptDate}"
                                             onclick="WdatePicker({dateFmt:'yyyyMMdd'})"/>
                                <h:outputLabel value="客户姓名:"/>
                                <p:inputText   value="#{custMngAction.paramBean.custName}" title="提示：多个客户姓名可使用“|”分割，如：张三|李四"/>
                            </h:panelGrid>
                            <h:panelGrid>
                                <p:commandButton id="qrybtn" style="width:90px;" value="查询"
                                                 action="#{custMngAction.onQuery}"
                                                 update="pdt,msgs">
                                </p:commandButton>

                                <p:commandButton ajax="false" id="btnExport" value="导出CSV"
                                                 style="width:90px;">
                                    <p:dataExporter type="csv" target="pdt" fileName="rpt#{custMngAction.paramBean.branchId}" encoding="GBK"
                                                    pageOnly="false"/>
                                </p:commandButton>
                            </h:panelGrid>
                        </h:panelGrid>
                    </p:panel>
                </div>

                <p:ajaxStatus style="height:20px;text-align:center">
                    <f:facet name="start">
                        <h:graphicImage value="/images/ajaxloadingbar.gif"/>
                    </f:facet>
                    <f:facet name="complete">
                        <h:outputText value=""/>
                    </f:facet>
                </p:ajaxStatus>

                <p:dataTable id="pdt" style="width:100%;"
                             lazy="true"
                             value="#{custMngAction.lazyDataModel}" var="record"
                             rowKey="#{record.guid}"
                             selectionMode="multiple" selection="#{custMngAction.selectedRecords}"
                             paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown} "
                             currentPageReportTemplate="{startRecord}-{endRecord} 共{totalRecords}笔"
                             paginator="true" rows="15"
                             paginatorPosition="top"
                             rowsPerPageTemplate="500,100,50,30,15"
                             emptyMessage="数据记录为空...">

                    <p:column style="text-align:center" >
                        <f:facet name="header">
                            客户名称
                        </f:facet>
                        <h:outputText value="#{record.custName}"/>
                    </p:column>
                    <p:column style="text-align:center" >
                        <f:facet name="header">
                            证件类型
                        </f:facet>
                        <h:outputText value="#{record.certType}"/>
                    </p:column>
                    <p:column style="text-align:center" >
                        <f:facet name="header">
                            证件号
                        </f:facet>
                        <h:outputText value="#{record.certNo}"/>
                    </p:column>
<!--
                    <p:column style="text-align:center" >
                        <f:facet name="header">
                            联系方式1
                        </f:facet>
                        <h:outputText value="#{record.contactInfo1}"/>
                    </p:column>
                    <p:column style="text-align:center" >
                        <f:facet name="header">
                            联系方式2
                        </f:facet>
                        <h:outputText value="#{record.contactInfo2}"/>
                    </p:column>
-->

                    <p:column style="text-align:center" sortBy="#{record.custmgrName}">
                        <f:facet name="header">
                            客户经理
                        </f:facet>
                        <h:outputText value="#{record.custmgrName}"/>
                    </p:column>

                    <p:column style="text-align:center"  sortBy="#{record.aumMonthCurr}">
                        <f:facet name="header">
                            月日均AUM
                        </f:facet>
                        <h:outputText value="#{record.aumMonthCurr}" style="float: right">
                            <f:convertNumber pattern="##,###,##0.00"/>
                        </h:outputText>
                    </p:column>

                    <f:facet name="footer">
                        <p:selectOneMenu id="custmgr" style="float:right;" rendered="#{fn:length(custMngAction.branchList) == 1}"
                                         value="#{custMngAction.custmgrId}">
                            <f:selectItems value="#{custMngAction.custmgrList}"/>
                        </p:selectOneMenu>
                        <p:commandButton value="客户分配" title="选择待分配客户的方法：直接点击客户所在的行进行单选、按住Shift+点击进行连续多选、按住Ctrl+点击进行挑选"
                                         rendered="#{fn:length(custMngAction.branchList) == 1}"
                                         icon="ui-icon-search" style="float:right;margin-top:-2px"
                                         update=":form:msgs,:form:pdt" action="#{custMngAction.onDispatch}"/>
                    </f:facet>
                </p:dataTable>
            </h:form>
        </div>
    </ui:define>
</ui:composition>